import request from "@/utils/request";

/**
 * 客户分组列表
 * @param { clientGroupListParams } params
 * @returns { clientGroupListData }
 */
export const clientGroupList = params => {
  return request({
    url: "/crm/group/list",
    method: "get",
    params
  });
};

/**
 * 客户分组详情
 * @param { string } customerGroupId -客户分组id
 * @returns {clientGroupEditParams}
 */
export const clientGroupDetail = customerGroupId => {
  return request({
    url: `/crm/group/getGroup/${customerGroupId}`,
    method: "get"
  });
};

/**
 * 表单字段
 * @returns { fieldListData } - 表单字段
 */
export const fieldList = () => {
  return request({
    url: `/crm/group/getGroupList`,
    method: "get"
  });
};

/**
 * 新增客户分组
 * @param { clientGroupAddParams } data
 */
export const clientGroupAdd = data => {
  return request({
    url: "/crm/group/add",
    method: "post",
    data
  });
};

/**
 * 编辑客户分组
 * @param { clientGroupEditParams } data
 */
export const clientGroupEdit = data => {
  return request({
    url: "/crm/group/update",
    method: "put",
    data
  });
};

/**
 * 客户分组状态
 * @param { string } customerGroupId -客户分组id
 * @param { boolean } status -状态
 */
export const clientGroupStatus = (customerGroupId, status) => {
  return request({
    url: `/crm/group/enable/${customerGroupId}`,
    method: "put",
    params: {
      status
    }
  });
};

/**
 * 删除客户分组
 * @param { string } customerGroupId -客户分组id
 */
export const clientGroupDelete = customerGroupId => {
  return request({
    url: `/crm/group/deleteGroup/${customerGroupId}`,
    method: "delete"
  });
};
